
export default [
    // 首页
    {
        path: '/home',
        component: () => import('@/pages/Home'),
        meta: {
            show: true
        }
    },
    // 搜索页
    {
        name: 'search', //用编程式导航传params参数时要起名。
        path: '/search/:keyword?', //params传参要占位。
        component: () => import('@/pages/Search'),
        meta: {
            show: true
        }
    },
    // 详情页
    {
        name: 'detail', //用编程式导航传params参数时要起名。
        path: '/detail/:skuid?', //params传参要占位。
        component: () => import('@/pages/Detail'),
        meta: {
            show: true
        }
    },
    // 添加购物车成功页
    {
        name: 'addCartSuccess',
        path: '/addCartSuccess',
        component: () => import('@/pages/AddCartSuccess'),
        meta: {
            show: true
        }
    },
    // 购物车
    {
        name: 'shopCart',
        path: '/shopCart',
        component: () => import('@/pages/ShopCart'),
        meta: {
            show: true
        }
    },
    // 登录
    {
        path: '/login',
        component: () => import('@/pages/Login'),
        meta: {
            show: false
        }
    },
    // 注册
    {
        path: '/register',
        component: () => import('@/pages/Register'),
        meta: {
            show: false
        }
    },
    // 结算页
    {
        path: '/trade',
        component: () => import('@/pages/Trade'),
        meta: {
            show: false
        },
        beforeEnter: (to, from, next) => {
            if (from.path == "/shopCart") {
                next()
            } else {
                next(from.path)
            }
        }
    },
    // 支付页
    {
        path: '/pay',
        component: () => import('@/pages/Pay'),
        meta: {
            show: false
        },
        beforeEnter: (to, from, next) => {
            if (from.path == "/trade") {
                next()
            } else {
                next(from.path)
            }
        }
    },
    // 支付成功页
    {
        path: '/paysuccess',
        component: () => import('@/pages/PaySuccess'),
        meta: {
            show: false
        }
    },
    // 个人中心页
    {
        path: '/center',
        component: () => import('@/pages/Center'),
        children: [
            {
                path: 'myOrder',
                component: () => import('@/pages/Center/myOrder')
            },
            {
                path: 'groupOrder',
                component: () => import('@/pages/Center/groupOrder')
            },
            //重定向
            {
                path: '/center',
                redirect: '/center/myOrder'
            }
        ]
    },

    // 重定向
    {
        path: '/',
        redirect: "/home"
    }
]